package ESP.Util;
/**
 * 获取非自动增长ID
 */
import java.util.Date;

public class IDFactory {
	/**
	 * @author 程尧
	 * @return 年月日时分秒
	 */
	public static String getID(){
		Date date=new Date();
		StringBuffer ss=new StringBuffer();
		StringBuffer mon = new StringBuffer(String.valueOf(date.getMonth()+1));
		StringBuffer dat = new StringBuffer(String.valueOf(date.getDate()));
		StringBuffer hour = new StringBuffer(String.valueOf(date.getHours()));
		StringBuffer min = new StringBuffer(String.valueOf(date.getMinutes()));
		StringBuffer second = new StringBuffer(String.valueOf(date.getSeconds()));
		if(mon.length()==1){
			mon=mon.insert(0, "0");
		}if(dat.length()==1){
			dat=dat.insert(0, "0");
		}if(hour.length()==1){
			hour=hour.insert(0, "0");
		}if(min.length()==1){
			min=min.insert(0, "0");
		}if(second.length()==1){
			second=second.insert(0, "0");
		}
		ss = ss.append((date.getYear()+1900)).append(mon).append(dat).append(hour).append(min).append(second);
		return ss.toString();
	}
	/**
	 * 插入数据库中的时间
	 */
	public static int[] getSqlTime(){
		Date date = new Date();
		int[] array = {date.getYear(),date.getMonth(),date.getDate()};
		return array;
	}
	/**
	 * 
	 * @return
	 */
	public static String logTime(){
		Date date=new Date();
		StringBuffer ss=new StringBuffer();
		StringBuffer mon = new StringBuffer(String.valueOf(date.getMonth()+1));
		StringBuffer dat = new StringBuffer(String.valueOf(date.getDate()));
		StringBuffer hour = new StringBuffer(String.valueOf(date.getHours()));
		StringBuffer min = new StringBuffer(String.valueOf(date.getMinutes()));
		StringBuffer second = new StringBuffer(String.valueOf(date.getSeconds()));
		if(mon.length()==1){
			mon=mon.insert(0, "0");
		}if(dat.length()==1){
			dat=dat.insert(0, "0");
		}if(hour.length()==1){
			hour=hour.insert(0, "0");
		}if(min.length()==1){
			min=min.insert(0, "0");
		}if(second.length()==1){
			second=second.insert(0, "0");
		}
		ss = ss.append((date.getYear()+1900)+"年").append(mon+"月").append(dat+"日").append(hour+"时").append(min+"分").append(second+"秒");
		return ss.toString();
	}
	/**
	 * 获取上传文件名称
	 */
	public static String getGroupName(String stu_grade, String major_name, String stu_class,
			String groupLeaderName, String task_id, String user_name){
		StringBuffer ss = new StringBuffer(stu_grade+major_name+stu_class+"_");
		ss.append(groupLeaderName+"_").append(task_id);
		if (user_name != null && !user_name.equals("")) {
			ss.append("+"+user_name);
		}
		return ss.toString();
	}
	public static void main(String[] args) {
		System.out.println(getID());
	}
	
}
